<?php
/**
 * auth WQl
 * 2021/7/8 17:55
 */


namespace m;


use think\facade\Db;

class AppTokenM extends AppBasicM
{
    use \Singleton;

    protected $name = "token";

    //刷新token
    public function refreshToken($token,$memberId,$platform)
    {
        $update = $this->where(['member_id'=>$memberId,'platform'=>$platform])
            ->data(['token'=>$token,'create_time'=>time()])
            ->save();
        if(!$update){
            $this->insert([
                    'platform'  =>$platform,
                    'token'     =>$token,
                    'member_id' =>$memberId,
                    'create_time'=> time(),
                ]);
        }
    }
}